package com.java.exer1;

public class RegexTest_3 {

    public static void main(String[] args) {
        //IP地址 1~255.0~255.0~255.0~255
        System.out.println(checkIP("101.0.0.0"));

    }

    /**
     * 检查IP地址
     */
    public static boolean checkIP(String ip) {
        return ip.matches("([1-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])");
    }
}
